package org.hp.intern.test;
import java.io.*;
import java.net.*;

public class MultiClient extends Thread{

	private Socket client;
	public MultiClient(Socket client){
		
		this.client = client;
	}
	public void run(){
		
		try{
			
		BufferedReader in = new BufferedReader(new InputStreamReader(client.getInputStream()));
		PrintWriter out  = new PrintWriter(client.getOutputStream());
		while(true){ 
			String str=in.readLine(); 
			out.println(str); 
			out.flush(); 
			if(str.equals("bye")) 
			break; 
          } 
            client.close(); 
		}catch(Exception e){
			
			System.err.println(e.toString());
		}
		
	}
	public static void main(String[] args)throws IOException{
		
		ServerSocket myserver = new ServerSocket(8090);
		while(true){

			MultiClient client = new MultiClient(myserver.accept());
			client.start();
			
		}
		
	}

}
